import { AbstractControl, ValidationErrors } from '@angular/forms';

export class PasswordValidators {
    static oldpasswordValid(control: AbstractControl): Promise<ValidationErrors | null> {
        return new Promise((resolve, reject) => {
            setTimeout(() => {
                if(control.value != 'guangyao'){
                    resolve({oldpassworldValid: true});
                }else{
                    resolve(null);
                }
            }, 200);
        })
    }

    static rePasswordValid(control: AbstractControl): ValidationErrors | null {
        let newPassword = control.get('newPassword');
        let rePassword = control.get('rePassword');
        if(newPassword.value !== rePassword.value)
            return {rePasswordValid: true};
        return null;
    }
}